#ifndef __CHIP_TS32XX_HAL_GPIO__
#define __CHIP_TS32XX_HAL_GPIO__

#ifdef __cplusplus
extern "C"
{
#endif

#include "chip_common_hal_def.h"
#include "../include.h"

#ifndef EFLASH_DATA_SEC_INDEX
#define EFLASH_DATA_SEC_INDEX 60
#endif

#ifndef GPIOA
#define GPIOA PA
#endif

#ifndef GPIOB
#define GPIOB PB
#endif

// #ifndef GPIOC
// #define GPIOC PC
// #endif

#ifndef xdata
#define xdata
#endif
extern u8 flash_data[];
extern bool need_lvd;
extern void tk_init(void);
extern u32 tk_process(void);

#define HAL_TimerStart(x) ll_timer_enable(x)

#define HAL_TimerStop(x) ll_timer_disable(x)

#define SWD_Disable() swd_disable()

#define HAL_TouchInit() tk_init();

#define HAL_TouchGetValue() tk_process()

#define HAL_GPIO_Config(GPIOx, Pins, ModeSel) ll_gpio_config(GPIOx, Pins, (TYPE_ENUM_LL_GPIO_ALL_MODE)ModeSel)

    bool HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);

    void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);

    void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);

    void HAL_TimerInit(unsigned char WhichTimer, u16 Period, unsigned char Psc, u8 Prio);

#define GetAdc()                          \
    {                                     \
        ll_adc_start_enable();            \
        while (!(LL_ADC_DONE_PEND_GET())) \
            ;                             \
        LL_ADC_DONE_PEND_CLR();           \
    }

    void EFlashInit(void);

    void LVDInit(void);


void WriteData(bool isValidData);

#ifdef __cplusplus
}
#endif
#endif
